package com.db.designpatterns.client;

import java.util.HashMap;
import java.util.Map;

import com.db.designpatterns.connector.ClientConnector;

public class LocalClientCache implements ClientCache {
	
	private Map<String, Object> cache = new HashMap<>();
	ClientConnector clientConnector;
	public LocalClientCache(ClientConnector clientConnector) {
		this.clientConnector = clientConnector;
		clientConnector.listen(new NotificationListener() {
			@Override
			public void actionListener(String name, Object o) {
				cache.put(name,o);
			}
		});
	}
	
	@Override
	public Object get(String name) {
		return cache.get(name);
	}

	@Override
	public void put(String name, Object o) {
		throw new UnsupportedOperationException();
	}

	@Override
	public void connect() {
	}

}
